package com.ihr360.payroll.config;

import com.ihr360.payroll.model.dto.attendance.plan.AttendancePlan;
import com.ihr360.payroll.model.dto.reference.ReferenceApplication;
import com.ihr360.payroll.model.dto.salary.basecode.SalaryFieldCategory;
import com.ihr360.payroll.model.dto.salary.basecode.SalaryFieldType;
import com.ihr360.payroll.model.dto.salary.basecode.SalaryTaxType;
import com.ihr360.payroll.model.dto.salary.basecode.TaxDivision;
import com.ihr360.payroll.model.dto.salary.meta.PayrollConfig;
import com.ihr360.payroll.model.dto.salary.meta.SalaryField;
import com.ihr360.payroll.model.dto.salary.meta.system.SystemSalaryField;
import com.ihr360.payroll.model.dto.salary.plan.SalaryPlan;
import com.ihr360.payroll.model.dto.salary.plan.config.PayslipConfig;
import com.ihr360.payroll.model.dto.salary.tax.SalaryTax;
import com.ihr360.payroll.model.dto.salary.tax.SalaryTaxRule;
import com.ihr360.payroll.model.dto.salary.tax.SalaryTaxTable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
import org.springframework.http.MediaType;

@Configuration
public class DataRestConfig {

    /**
     * 针对Spring Data Rest的配置
     * @return
     */
    @Bean
    public RepositoryRestConfigurer repositoryRestConfigurer() {
        return new RepositoryRestConfigurerAdapter() {
            @Override
            public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
                config.exposeIdsFor(TaxDivision.class);
                config.exposeIdsFor(SalaryTaxType.class);
                config.exposeIdsFor(SalaryTaxRule.class);
                config.exposeIdsFor(TaxDivision.class);
                config.exposeIdsFor(SalaryTax.class);
                config.exposeIdsFor(SalaryFieldCategory.class);
                config.exposeIdsFor(SystemSalaryField.class);
                config.exposeIdsFor(SalaryFieldType.class);
                config.exposeIdsFor(AttendancePlan.class);
                config.exposeIdsFor(PayrollConfig.class);
                config.exposeIdsFor(SalaryPlan.class);
                config.exposeIdsFor(SalaryField.class);
                config.exposeIdsFor(PayslipConfig.class);
                config.exposeIdsFor(SalaryTaxTable.class);
                config.exposeIdsFor(ReferenceApplication.class);
                config.setDefaultMediaType(MediaType.APPLICATION_JSON_UTF8);
            }
        };
    }


}
